﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace GameBase
{
    public class LoopSprite : My2DSprite
    {
        private int endFrameCount = 0;

        public LoopSprite(string imgStr, int nTexture, Vector2 pos, float scale, float delay)
            : base(imgStr, nTexture, pos, scale, delay)
        {
        }

        public LoopSprite(Texture2D texture, int nTexture, Vector2 pos, float scale, float delay)
            : base(texture, nTexture, pos, scale, delay)
        {
        }

        public override void update(GameTime gameTime)
        {
            int delta = (int)(gameTime.TotalGameTime.TotalMilliseconds / NomalDelay);
            iTexture = (delta) % nTexture;
            if (iTexture == nTexture - 1)            
                endFrameCount++;            
            else            
                endFrameCount = 0;            
        }

        public override bool isEndOfFrame()
        {
            return (iTexture == nTexture - 1 && endFrameCount == 1);
        }
    }
}
